#define _CRT_SECURE_NO_WARNINGS 1

class Solution {
public:
    string printBin(double num)
    {
        std::string retBin;
        retBin += "0.";

        double x = 1.0 / 2;
        for (int i = 1; i <= 30; ++i)
        {
            if (num >= x)
            {
                num -= x;
                retBin += '1';
            }
            else
            {
                retBin += '0';
            }

            if (num == 0.0)
            {
                return retBin;
            }

            x = 1.0 * x / 2;
        }

        return std::string("ERROR");
    }
};